
import java.security.spec.RSAOtherPrimeInfo;
import java.util.*;
import java.io.*;

public class Main {
    public static void main1(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("数组个数：");
        int n=sc.nextInt();
        int[] a=new int[n];
        System.out.println("请输入数组：");
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[i] == a[j]) {
                    count++;
                }
            }
            if (count == 2)
                System.out.println(a[i]);
        }
    }


    public static Integer func(int[] arr,int n){
        for (int i = 0; i < n; i++) {
            int count=0;
            for (int j = 0; j < n; j++) {
                if(arr[i]==arr[j]){
                    count++;
                }
            }
            if(count==1)
                System.out.println(arr[i]);
        }
        return null;
    }
    public static void main3(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("数组个数：");
        int n=sc.nextInt();
        int[] a=new int[n];
        System.out.println("请输入数组：");
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        System.out.println("数组中只出现一次的数字为：");
        func(a,n);
    }


    public static int NumberOf(int n){
        int count=0;
        for (int i = 0; i < 32; i++) {
            if((n&1)==1){
                count++;
            }
            n=n>>1;
        }
        return count;
    }
    public static void main2(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int n=sc.nextInt();
        System.out.println("该数二进制中1的个数为：");
        int ret=NumberOf(n);
        System.out.println(ret);
    }


    public static int[] BubbleSort(int[] a){
        int tmp;
        boolean exchange=false;
        for (int i = 0; i < a.length-1; i++) {
            for (int j = 0; j <a.length-1-i ; j++) {
                if (a[j] > a[j + 1]) {
                    tmp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = tmp;
                    exchange = true;
                }
            }
            if(exchange==false){
                break;
            }
        }
        return a;
    }
    public static void main(String[] args) {
        int[] Arr = {18,32,41,52,0,0,6,61,0,5,4,72,86,79,0,565,0};
        System.out.println("原数组为：");
        System.out.println(Arrays.toString(Arr));
        int n=0;
        for (int i = 0; i < Arr.length; i++) {
            if(Arr[i]==0){
                n++;
            }
        }
        int[] newArr=new int[Arr.length-n];
        int index=0;
        for (int i = 0;i<Arr.length ; i++) {
            if(Arr[i]!=0){
                newArr[index++]=Arr[i];
            }
        }
        System.out.println("去0后的排序数组为：");
        System.out.println(Arrays.toString(BubbleSort(newArr)));
    }
}